#include <cstdio>
#include <cstring>

int f[ 1001 ][ 1001 ], d[ 1001 ][ 1001 ];

void init( )
{
    int i, j, k;
    bool visit[ 1001 ];
    for ( i = 0; i <= 1000; i++ )
        f[ i ][ 0 ] = 0;
    memset( d, 0, sizeof( d ) );
    for ( i = 1; i <= 1000; i++ )
        for ( j = 1; j <= i; j++ )
        {
            memset( visit, 0, sizeof( visit ) );
            for ( k = j; k <= i; k += j )
                if ( i - k < j )
                    visit[ f[ j ][ i - k ] ] = 1;
                else
                    visit[ f[ i - k ][ j ] ] = 1;
            for ( k = 0; visit[ k ]; k++ );
            f[ i ][ j ] = k;
            if ( f[ i ][ j ] )
            {
                for ( k = j; k <= i; k += j )
                    if ( i - k < j )
                    {
                        if ( !f[ j ][ i - k ] && d[ i ][ j ] < d[ j ][ i - k ] + 1 )
                            d[ i ][ j ] = d[ j ][ i - k ] + 1;
                    }
                    else
                        if ( !f[ i - k ][ j ] && d[ i ][ j ] < d[ i - k ][ j ] + 1 )
                            d[ i ][ j ] = d[ i - k ][ j ] + 1;
            }
            else
            {
                d[ i ][ j ] = 100000000;
                for ( k = j; k <= i; k += j )
                    if ( i - k < j )
                    {
                        if ( d[ i ][ j ] > d[ j ][ i - k ] + 1 )
                            d[ i ][ j ] = d[ j ][ i - k ] + 1;
                    }
                    else
                        if ( d[ i ][ j ] > d[ i - k ][ j ] + 1 )
                            d[ i ][ j ] = d[ i - k ][ j ] + 1;
            }
        }
}

int main( )
{
    int ans, n, a, b;
    init( );
    while ( scanf("%d", &n) != EOF )
    {
        ans = 0;
        while ( n-- )
        {
            scanf("%d%d", &a, &b);
            if ( a < b )
            {
//                printf("%d %d\n", f[ b ][ a ], d[ b ][ a ]);
                if ( ans < d[ b ][ a ] )
                    ans = d[ b ][ a ];
            }
            else
            {
//                printf("%d %d\n", f[ a ][ b ], d[ a ][ b ]);
                if ( ans < d[ a ][ b ] )
                    ans = d[ a ][ b ];
            }
        }
        if ( ans & 1 )
            puts("MM");
        else
            puts("GG");
    }
    return 0;
}
